package logic

import (
	"code.bydev.io/cht/customer/kyc_admin_service/internal/domain/cron"
	"code.bydev.io/cht/customer/kyc_admin_service/internal/pkg/kycadminrepo"
	"code.bydev.io/cht/customer/kyc_admin_service/service/job/internal/svc"
	"code.bydev.io/frameworks/byone/core/logc"
	"context"
)

// 定时任务逻辑
func doKyc_admin_cronJob(ctx context.Context, svcCtx *svc.ServiceContext) error {
	logc.Infow(ctx, "doKyc_admin_cronJob start")
	e := svcCtx.NothingEnv
	repo := kycadminrepo.New(
		e.Logger(),
		e.ChtKycDB(),
		e.UserDB(),
		e.SecHub(),
		e.Teller(),
		e.KycSvc(),
		e.InternalDataKey(),
		e.Kafka(),
	)
	imageHandler := cron.NewDomain(e.Logger(), repo, e.Teller(), svcCtx.Config.Redis.NewRedis(), e.SecHub(), svcCtx.KafkaProducer)
	if err := imageHandler.ActionImageHandler(ctx); err != nil {
		logc.Errorw(ctx, "imageHandler.ActionImageHandler error", logc.Field("err", err))
		return err
	}
	logc.Infow(ctx, "doKyc_admin_cronJob end")
	return nil
}
